package com.ldy.core.util;

import java.io.InputStream;
import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ldy.core.entity.BaseMenu;

/**
 * 菜单配置工具
 */
public class MenuConfigUtil {

	public static List<BaseMenu> get() {
		try {
			// 创建 ObjectMapper 实例
			ObjectMapper objectMapper = new ObjectMapper();

			// 读取 resources 目录下的 JSON 文件
			InputStream inputStream = MenuConfigUtil.class.getResourceAsStream("/menu-config.json");

			// 将 JSON 数组内容转换为 List<User> 对象
			List<BaseMenu> menus = objectMapper.readValue(inputStream, new TypeReference<List<BaseMenu>>() {
			});

			return menus;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
